

import 'package:flutter/material.dart';

class DialogWidget {
  static void showAlertDialog(BuildContext context,{String title="提示",String content="确定删除吗？",bool showCancel= true,String cancelText = "取消"
  ,String confirmText = "确定",VoidCallback confirmOnTap }){
    showDialog(
        context: context,
        builder: (context) {
          return AlertDialog(
            title: Text(title),
            content: Text(content),
            actions: <Widget>[
              showCancel?FlatButton(
                  child: Text(cancelText),
                  onPressed: (){
                    Navigator.pop(context, "cancel");
                  }):Container(),
              FlatButton(
                  child: Text(confirmText),
                  onPressed: (){
                    if(confirmOnTap!=null)
                    confirmOnTap();
                    Navigator.pop(context, "yes");
                  }),
            ],
          );
        });
  }
}
